// @ts-nocheck
import React, { useEffect, useState } from "react";
import { NavBar } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import "./index.less";
import { getEvaluateList } from "../../service";
import { getCurrentUserInfo } from "@/utils/authority";
import { safeParseJSON } from "@/utils";

const Evaluate: React.FC<any> = () => {
	const navigate = useNavigate();
	const userId = getCurrentUserInfo()?.data?.id;

	const [list, setList] = useState([]);
	const getListData = async () => {
		const params = {
			assignee: userId,
			current: 1,
			size: 10000,
		};
		try {
			const { data } = await getEvaluateList(params);
			setList(data?.records);
		} catch {}
	};
	useEffect(() => {
		getListData();
	}, []);

	return (
		<div className="evaluate-contarnier">
			<div className="header">
				<div>
					<NavBar onBack={() => navigate("/user/trends")}>
						<div className="commontitle">待我评价</div>
					</NavBar>
				</div>
			</div>
			<div className="evaluate-box">
				{list.map((item) => (
					<div
						className="evaluate-box-card"
						key={item.id}
						onClick={() => navigate("/user/trends/evaluationPublication", { state: item })}>
						<div className="evaluate-box-card-title">
							<div>{safeParseJSON(item?.formCommitData)?.questiontitle || ""}</div>
							<div className={item?.processDefinitionName == "社区服务流程" ? "service" : "event"}>
								{item?.processDefinitionName == "社区服务流程" ? "服务" : "事件"}
							</div>
						</div>
						<div className="evaluate-box-card-time">{item?.createTime}</div>
					</div>
				))}
			</div>
		</div>
	);
};

export default Evaluate;
